package com.example.measuringporject;

import com.example.measuringproject.db.MeasuringDBOpenHelper;

import android.R.string;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
	
	public String session="default";
	public static String measureWorkingSet;
	public static String colorWorkingSet;

	MeasuringDBOpenHelper dbhelper;
	SQLiteDatabase database;
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		measureWorkingSet = "defaultMeasureSet";
		colorWorkingSet = "defaultColorSet";
		
		//creating database
		dbhelper = new MeasuringDBOpenHelper(this);
		database = dbhelper.getWritableDatabase();
		
		int sess = dbhelper.addSession(database,"sess1");
		dbhelper.addPicture(database,"root/pics/pic1.png",0.3);
		dbhelper.addSet(database, "set1", "color", sess);
		
		TextView editText = (TextView) findViewById(R.id.textView2);
		//editText.setText(dbhelper.getSession(database).get(sess));
		dbhelper.onUpgrade(database, 1, 1);
		
		this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); //hides auto keyboard popup
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	
	public void main_move_to_take_photo(View view) {
		Intent intent = new Intent(this, Camera.class);
		startActivity(intent);
	}
	
	public void main_move_to_gallery(View view) {
		Intent intent = new Intent(this, Gallery.class);
		startActivity(intent);
	}

	public void main_move_to_sets(View view) {
		Intent intent = new Intent(this, Sets.class);
		startActivity(intent);
	}
	
	
	public void main_set_session(View view) {
		EditText editText = (EditText) findViewById(R.id.editText_set_session);
		this.session = editText.getText().toString();
	}
	
	
	public void main_move_to_tes_pic(View view) {
		Intent intent = new Intent(this, Picture.class);
		startActivity(intent);
	}
}
